package zwp.example.demo1.demo_controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import zwp.example.demo1.demo_thread_pool.DemoSleepAndWaitService;

/**
 * @author zwp14
 * 线程睡眠和等待业务入口
 */
@RestController
@RequestMapping("/sleep_wait")
@RequiredArgsConstructor
public class DemoSleepAndWaitController {


    private final DemoSleepAndWaitService sleepAndWaitService;

    /**
     * 线程睡眠测试
     *
     * @return 成功标识
     */
    @PostMapping("/sleep")
    public String sleepTest() {
        return sleepAndWaitService.sleepTest();
    }

    /**
     * 线程等待测试1
     */
    @PostMapping("/wait1")
    public void waitTest1() {
        sleepAndWaitService.waitTest1();
    }

    /**
     * 线程等待测试2
     */
    @PostMapping("/wait2")
    public void waitTest2() {
        sleepAndWaitService.waitTest2();
    }

    /**
     * 线程等待测试3
     */
    @PostMapping("/wait3")
    public void waitTest3() {
        sleepAndWaitService.waitTest3();
    }

    /**
     * 线程等待测试4
     */
    @PostMapping("/wait4")
    public void waitTest4() {
        sleepAndWaitService.waitTest4();
    }
}
